package ch04
{
	import flash.display.GradientType;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.geom.Matrix;

	/**
	 * 使用 beingGradientFill 创建渐变填充
	 * @author sjp
	 *
	 */
	public class GradientFill extends Sprite
	{
		public function GradientFill()
		{
			init();
		}

		private function init():void
		{
			graphics.lineStyle(1);
//			var colors:Array=[0xffffff, 0xff0000];
//			var alphas:Array=[1, 1];
//			var ratios:Array=[0, 255];
			var colors:Array=[0xffffff, 0x0000ff, 0xff0000];
			var alphas:Array=[0.1, 0.5, 1];
			var ratios:Array=[0, 128, 255];
			var matrix:Matrix=new Matrix();
			matrix.createGradientBox(100, 100, -Math.PI / 4, 0, 0);
//			graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix);
			graphics.beginGradientFill(GradientType.RADIAL, colors, alphas, ratios, matrix);
			graphics.drawRect(0, 0, 100, 100);
			graphics.endFill();
		}
	}
}